//
//  SendedJobListTableViewCell.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/6/14.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "SendedJobListTableViewCell.h"
@interface SendedJobListTableViewCell()
@property (nonatomic, strong) UILabel *titleLabel; // 标题
@property (nonatomic, strong) UIButton *editBtn; // 编辑
@property (nonatomic, strong) UIButton *deleteBtn; // 删除
@end

@implementation SendedJobListTableViewCell
- (void)setDataDic:(NSDictionary *)dataDic
{
    self.titleLabel.text = [NSString stringWithFormat:@"    %@",dataDic[@"skilltitle"]];
}
- (void)setJobsDataDic:(NSDictionary *)JobsDataDic
{
    self.titleLabel.text = [NSString stringWithFormat:@"    %@",JobsDataDic[@"jobtitle"]];
}
- (void)btnAction:(UIButton *)btn
{
    if ([btn isEqual:self.editBtn]) {
        NSLog(@"编辑");
        if (self.editBtnBlock) {
            self.editBtnBlock();
        }
    }
    if ([btn isEqual:self.deleteBtn]) {
        NSLog(@"删除");
        if (self.deleteBtnBlock) {
            self.deleteBtnBlock();
        }
    }
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsZero;
        self.backgroundColor = [UIColor clearColor];
        
        [self.contentView addSubview:self.titleLabel];
        __weak typeof(self)weakself = self;
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(weakself.mas_bottom);
            make.left.equalTo(weakself.mas_left).offset(15 / WIDTH_6S_SCALE);
            make.right.equalTo(weakself.mas_right).offset(-20 / WIDTH_6S_SCALE);
            make.height.mas_offset(50 / HEIGHT_6S_SCALE);
        }];
        self.titleLabel.layer.cornerRadius = 5;
        self.titleLabel.layer.masksToBounds = YES;
        
        _editBtn = [[UIButton alloc]init];
        _editBtn.backgroundColor = [UIColor clearColor];
        [_editBtn setImage:[UIImage imageNamed:@"list_edit"] forState:UIControlStateNormal];
        [_editBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_editBtn];
        [_editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakself.titleLabel.mas_centerY);
            make.right.equalTo(weakself.titleLabel.mas_right).offset(- 30 / WIDTH_6S_SCALE);
            make.height.with.mas_equalTo(40 / WIDTH_6S_SCALE);
        }];
        
        _deleteBtn = [[UIButton alloc]init];
        _deleteBtn.backgroundColor = [UIColor clearColor];
        [_deleteBtn setImage:[UIImage imageNamed:@"list_deletebtn"] forState:UIControlStateNormal];
        [_deleteBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_deleteBtn];
        [_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.titleLabel.mas_top).offset(-10 / WIDTH_6S_SCALE);
            make.right.equalTo(weakself.titleLabel.mas_right).offset(10 / WIDTH_6S_SCALE);
            make.height.with.mas_equalTo(30 / WIDTH_6S_SCALE);
        }];
    }
    
    return self;
}
#pragma mark - init
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectZero];
        _titleLabel.backgroundColor = getColor(whiteColor);
        _titleLabel.textColor = getColor(textColor);
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = DEF_FontSize_14;
        [_titleLabel sizeToFit];
        _titleLabel.text = @"    UI设计师两名";
    }
    return _titleLabel;
}

@end
